package com.atguigu;


public class Consumer implements Runnable {
    private final SharedResource resource;

    public Consumer(SharedResource resource) {
        this.resource = resource;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; i < 10; i++) {
                resource.consume();
                Thread.sleep(1500); // 模拟消费时间
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}